package com.sky.controller.user;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController("userShopController") // 避免与管理端的ShopController的Bean产生冲突
@RequestMapping("/user/shop")
@Slf4j
@Api(tags = "营业状态相关接口")
public class ShopController {

//    注入redis
    @Autowired
    RedisTemplate redis;
    private static final String KEY = "SHOP_STATUS" ;


    /**
     * 获取状态接口
     * @return
     */
    @GetMapping("/status")
    @ApiOperation("获取状态接口")
    public Result getStatus(){
        Integer status = (Integer) redis.opsForValue().get(KEY);
        log.info("用户端：店铺当前的营业状态为：{}",status ==1 ?"营业中":"打样中");
        return Result.success(status);
    }

}
